<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="shared/css_js::header">
	<title>jQuery WeUI</title>
	<link rel="stylesheet" type="text/css" href="/static/css/weuicss/weui.min.css"/>
</head>
<style>
	.mycar{border-right:1px solid #b6b6b6}
	.del{border:1px solid red}
	.mui-table-view .mui-media-object {
		line-height: 42px;
		 max-width: 420px;
		height: 42px;
	}
</style>
<body>
<header class="mui-bar mui-bar-nav">
	<a class=" mui-icon mui-icon-left-nav " href="/person/carhome"></a>
	<h1 class="mui-title"><font size="4"><b>我的车库</b></font></h1>
</header>
<nav class="mui-bar mui-bar-tab">
	<a class="weui-btn weui-btn_warn" onclick="addcar()">新增车型</a>
</nav>
<div class="mui-content">
	<div th:each="car:${car}">
		<ul class="mui-table-view" th:onclick="'javascript:carinfo(\''+${car.custcarid}+'\')'">
			<li class="mui-table-view-cell mui-media" style="line-height: 2">
				<div class="weui-flex" >
					<div class="weui-flex__item mycar" >
						<img class="mui-media-object mui-pull-left " style="width: 60px" th:src="'/img/caricon/'+${car.brandlogo}"/>
					</div>
					<div class="weui-flex__item" style="flex-grow: 4">
						<h4 style="margin-bottom: 15px" >&nbsp;&nbsp;<span th:text="${car.brandname+car.carlinename}">一汽大众奥迪-A4L</span></h4>
						<h5 >&nbsp;&nbsp;&nbsp;<span th:text="${car.carvol+'   '+car.caryear}">2009款  2.0T 无极 技术版</span></h5>
					</div>
				</div>
			</li>
		</ul>
		<div class="weui-cells weui-cell_access" style="margin-top: 0px">
			<div class="weui-cell" style="line-height:1">
				<div class="weui-cell__bd">
					<div class="weui-flex">
						<div class="weui-flex__item">
							<a th:onclick="'javascript:setdefault(this,\''+${car.custcarid}+'\')'" th:if="${car.setdefault==0}" class="weui-btn weui-btn_default del" style="width: 130px;height: 30px;background-color: white"><h4 class="fff" style="color: red" >设为默认</h4></a>
							<a th:onclick="'javascript:setdefault(this,\''+${car.custcarid}+'\')'" th:if="${car.setdefault==1}" class="weui-btn weui-btn_default del" style="width: 150px;height: 30px;background-color: white"><h4 class="fff" style="color: red" >♥ 已设为默认</h4></a>
						</div>
						<div class="weui-flex__item">
							<a class="weui-btn weui-btn_default del" style="width: 120px;height: 30px;background-color: white" th:onclick="'javascript:deletecar(\''+${car.custcarid}+'\')'"><h4 style="color: red">删除</h4></a>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="weui-cells__title" align="center"></div><!--间隔一下-->
	</div>


</div>

</body>
<script>
    /*点击大的块时候把当前车型信息带出去*/
    function carinfo(custcarid) {
        location.href="/person/carhome?custcarid="+custcarid;
    }
    /*点击设定默认*/
    function setdefault($this,custcarid) {
        var a=$($this).find(".fff").text();
        if(a=='设为默认'){
            mui.ajax('/person/setdefault', {
                data: {
                    custcarid:custcarid,
                },
                type: 'get',//HTTP请求类型
                success: function (data) {
                    location.href="/person/mycar";
                },
                error: function (data) {
                    $.alert('请重试!')
                }
            })
		}
    }

    /*新增车型*/
    function addcar() {
		location.href="/person/addcar";
    }

    /*删除车型*/
    function deletecar(custcarid) {
		location.href="/person/deletecar?custcarid="+custcarid;
    }
</script>
</html>
